home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / doom / axxwar_1.zip / SOURCES / DOORS.QC < prev    next >
Text File  |  1997-01-27  |  18KB  |  787 lines

  1. // AxxCfg II Release 6
  2.  
  3. float DOOR_START_OPEN = 1;
  4. float DOOR_DONT_LINK = 4;
  5. float DOOR_GOLD_KEY = 8;
  6. float DOOR_SILVER_KEY = 16;
  7. float DOOR_TOGGLE = 32;
  8.  
  9. /*
  10.  
  11. Doors are similar to buttons, but can spawn a fat trigger field around them
  12. to open without a touch, and they link together to form simultanious
  13. double/quad doors.
  14.  
  15. Door.owner is the master door.  If there is only one door, it points to itself.
  16. If multiple doors, all will point to a single one.
  17.  
  18. Door.enemy chains from the master door through all doors linked in the chain.
  19.  
  20. */
  21.  
  22. /*
  23. =============================================================================
  24.  
  25. THINK FUNCTIONS
  26.  
  27. =============================================================================
  28. */
  29.  
  30. void() door_go_down;
  31. void() door_go_up;
  32.  
  33. void() door_blocked =
  34. {
  35.     T_Damage (other, self, self, self.dmg);
  36.     
  37. // if a door has a negative wait, it would never come back if blocked,
  38. // so let it just squash the object to death real fast
  39.     if (self.wait >= 0)
  40.     {
  41.         if (self.state == STATE_DOWN)
  42.             door_go_up ();
  43.         else
  44.             door_go_down ();
  45.     }
  46. };
  47.  
  48.  
  49. void() door_hit_top =
  50. {
  51.     sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
  52.     self.state = STATE_TOP;
  53.     if (self.spawnflags & DOOR_TOGGLE)
  54.         return;        // don't come down automatically
  55.     self.think = door_go_down;
  56.     self.nextthink = self.ltime + self.wait;
  57. };
  58.  
  59. void() door_hit_bottom =
  60. {
  61.     sound (self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
  62.     self.state = STATE_BOTTOM;
  63. };
  64.  
  65. void() door_go_down =
  66. {
  67.     sound (self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
  68.     if (self.max_health)
  69.     {
  70.         self.takedamage = DAMAGE_YES;
  71.         self.health = self.max_health;
  72.     }
  73.     
  74.     self.state = STATE_DOWN;
  75.     SUB_CalcMove (self.pos1, self.speed, door_hit_bottom);
  76. };
  77.  
  78. void() door_go_up =
  79. {
  80.     if (self.state == STATE_UP)
  81.         return;        // allready going up
  82.  
  83.     if (self.state == STATE_TOP)
  84.     {    // reset top wait time
  85.         self.nextthink = self.ltime + self.wait;
  86.         return;
  87.     }
  88.     
  89.     sound (self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
  90.     self.state = STATE_UP;
  91.     SUB_CalcMove (self.pos2, self.speed, door_hit_top);
  92.  
  93.     SUB_UseTargets();
  94. };
  95.  
  96.  
  97. /*
  98. =============================================================================
  99.  
  100. ACTIVATION FUNCTIONS
  101.  
  102. =============================================================================
  103. */
  104.  
  105. void() door_fire =
  106. {
  107.     local entity     oself;
  108.     local entity    starte;
  109.  
  110.     if (self.owner != self)
  111.         objerror ("door_fire: self.owner != self");
  112.  
  113. // play use key sound
  114.  
  115.     if (self.items)
  116.         sound (self, CHAN_VOICE, self.noise4, 1, ATTN_NORM);
  117.  
  118.     self.message = string_null;        // no more message
  119.     oself = self;
  120.  
  121.     if (self.spawnflags & DOOR_TOGGLE)
  122.     {
  123.         if (self.state == STATE_UP || self.state == STATE_TOP)
  124.         {
  125.             starte = self;
  126.             do
  127.             {
  128.                 door_go_down ();
  129.                 self = self.enemy;
  130.             } while ( (self != starte) && (self != world) );
  131.             self = oself;
  132.             return;
  133.         }
  134.     }
  135.     
  136. // trigger all paired doors
  137.     starte = self;
  138.     do
  139.     {
  140.         door_go_up ();
  141.         self = self.enemy;
  142.     } while ( (self != starte) && (self != world) );
  143.     self = oself;
  144. };
  145.  
  146.  
  147. void() door_use =
  148. {
  149.     local entity oself;
  150.  
  151.     self.message = "";            // door message are for touch only
  152.     self.owner.message = "";    
  153.     self.enemy.message = "";
  154.     oself = self;
  155.     self = self.owner;
  156.     door_fire ();
  157.     self = oself;
  158. };
  159.  
  160.  
  161. void() door_trigger_touch =
  162. {
  163.     if (other.health <= 0)
  164.         return;
  165.  
  166.     if (time < self.attack_finished)
  167.         return;
  168.     self.attack_finished = time + 1;
  169.  
  170.     activator = other;
  171.  
  172.     self = self.owner;
  173.     door_use ();
  174. };
  175.  
  176.  
  177. void() door_killed =
  178. {
  179.     local entity oself;
  180.     
  181.     oself = self;
  182.     self = self.owner;
  183.     self.health = self.max_health;
  184.     self.takedamage = DAMAGE_NO;    // wil be reset upon return
  185.     door_use ();
  186.     self = oself;
  187. };
  188.  
  189.  
  190. /*
  191. ================
  192. door_touch
  193.  
  194. Prints messages and opens key doors
  195. ================
  196. */
  197. void() door_touch =
  198. {
  199. if ((other.classname != "player") && (other.classname != "cbot")) // AXXEL
  200. //    if (other.classname != "player") // Original code
  201.         return;
  202.     if (self.owner.attack_finished > time)
  203.         return;
  204.  
  205.     self.owner.attack_finished = time + 2;
  206.  
  207.     if ((self.owner.message != "") &&    (other.classname == "player")) // AXXEL
  208. //    if (self.owner.message != "") // Original code    
  209.  
  210.     {
  211.         centerprint (other, self.owner.message);
  212.         sound (other, CHAN_VOICE, "misc/talk.wav", 1, ATTN_NORM);
  213.     }
  214.     
  215.     if (other.classname == "cbot")    return;  // AXXEL
  216.  
  217.  
  218. // key door stuff
  219.     if (!self.items)
  220.         return;
  221.  
  222. // FIXME: blink key on player's status bar
  223.     if ( (self.items & other.items) != self.items )
  224.     {
  225.         if (self.owner.items == IT_KEY1)
  226.         {
  227.             if (world.worldtype == 2)
  228.             {
  229.                 centerprint (other, "You need the silver keycard");
  230.                 sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  231.             }
  232.             else if (world.worldtype == 1)
  233.             {
  234.                 centerprint (other, "You need the silver runekey");
  235.                 sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  236.             }
  237.             else if (world.worldtype == 0)
  238.             {
  239.                 centerprint (other, "You need the silver key");
  240.                 sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  241.             }
  242.         }
  243.         else
  244.         {
  245.             if (world.worldtype == 2)
  246.             {
  247.                 centerprint (other, "You need the gold keycard");
  248.                 sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  249.             }
  250.             else if (world.worldtype == 1)
  251.             {
  252.                 centerprint (other, "You need the gold runekey");
  253.                 sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);            
  254.             }
  255.             else if (world.worldtype == 0)
  256.             {
  257.                 centerprint (other, "You need the gold key");
  258.                 sound (self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  259.             }
  260.         }
  261.         return;
  262.     }
  263.  
  264.     other.items = other.items - self.items;
  265.     self.touch = SUB_Null;
  266.     if (self.enemy)
  267.         self.enemy.touch = SUB_Null;    // get paired door
  268.     door_use ();
  269. };
  270.  
  271. /*
  272. =============================================================================
  273.  
  274. SPAWNING FUNCTIONS
  275.  
  276. =============================================================================
  277. */
  278.  
  279.  
  280. entity(vector fmins, vector fmaxs) spawn_field =
  281. {
  282.     local entity    trigger;
  283.     local    vector    t1, t2;
  284.  
  285.     trigger = spawn();
  286.     trigger.movetype = MOVETYPE_NONE;
  287.     trigger.solid = SOLID_TRIGGER;
  288.     trigger.owner = self;
  289.     trigger.touch = door_trigger_touch;
  290.  
  291.     t1 = fmins;
  292.     t2 = fmaxs;
  293.     setsize (trigger, t1 - '60 60 8', t2 + '60 60 8');
  294.     return (trigger);
  295. };
  296.  
  297.  
  298. float (entity e1, entity e2) EntitiesTouching =
  299. {
  300.     if (e1.mins_x > e2.maxs_x)
  301.         return FALSE;
  302.     if (e1.mins_y > e2.maxs_y)
  303.         return FALSE;
  304.     if (e1.mins_z > e2.maxs_z)
  305.         return FALSE;
  306.     if (e1.maxs_x < e2.mins_x)
  307.         return FALSE;
  308.     if (e1.maxs_y < e2.mins_y)
  309.         return FALSE;
  310.     if (e1.maxs_z < e2.mins_z)
  311.         return FALSE;
  312.     return TRUE;
  313. };
  314.  
  315.  
  316. /*
  317. =============
  318. LinkDoors
  319.  
  320.  
  321. =============
  322. */
  323. void() LinkDoors =
  324. {
  325.     local entity    t, starte;
  326.     local vector    cmins, cmaxs;
  327.  
  328.     if (self.enemy)
  329.         return;        // already linked by another door
  330.     if (self.spawnflags & 4)
  331.     {
  332.         self.owner = self.enemy = self;
  333.         return;        // don't want to link this door
  334.     }
  335.  
  336.     cmins = self.mins;
  337.     cmaxs = self.maxs;
  338.     
  339.     starte = self;
  340.     t = self;
  341.     
  342.     do
  343.     {
  344.         self.owner = starte;            // master door
  345.  
  346.         if (self.health)
  347.             starte.health = self.health;
  348.         if (self.targetname)
  349.             starte.targetname = self.targetname;
  350.         if (self.message != "")
  351.             starte.message = self.message;
  352.  
  353.         t = find (t, classname, self.classname);    
  354.         if (!t)
  355.         {
  356.             self.enemy = starte;        // make the chain a loop
  357.  
  358.         // shootable, fired, or key doors just needed the owner/enemy links,
  359.         // they don't spawn a field
  360.     
  361.             self = self.owner;
  362.  
  363.             if (self.health)
  364.                 return;
  365.             if (self.targetname)
  366.                 return;
  367.             if (self.items)
  368.                 return;
  369.  
  370.             self.owner.trigger_field = spawn_field(cmins, cmaxs);
  371.  
  372.             return;
  373.         }
  374.  
  375.         if (EntitiesTouching(self,t))
  376.         {
  377.             if (t.enemy)
  378.                 objerror ("cross connected doors");
  379.             
  380.             self.enemy = t;
  381.             self = t;
  382.  
  383.             if (t.mins_x < cmins_x)
  384.                 cmins_x = t.mins_x;
  385.             if (t.mins_y < cmins_y)
  386.                 cmins_y = t.mins_y;
  387.             if (t.mins_z < cmins_z)
  388.                 cmins_z = t.mins_z;
  389.             if (t.maxs_x > cmaxs_x)
  390.                 cmaxs_x = t.maxs_x;
  391.             if (t.maxs_y > cmaxs_y)
  392.                 cmaxs_y = t.maxs_y;
  393.             if (t.maxs_z > cmaxs_z)
  394.                 cmaxs_z = t.maxs_z;
  395.         }
  396.     } while (1 );
  397.  
  398. };
  399.  
  400.  
  401. /*QUAKED func_door (0 .5 .8) ? START_OPEN x DOOR_DONT_LINK GOLD_KEY SILVER_KEY TOGGLE
  402. if two doors touch, they are assumed to be connected and operate as a unit.
  403.  
  404. TOGGLE causes the door to wait in both the start and end states for a trigger event.
  405.  
  406. START_OPEN causes the door to move to its destination when spawned, and operate in reverse.  It is used to temporarily or permanently close off an area when triggered (not usefull for touch or takedamage doors).
  407.  
  408. Key doors are allways wait -1.
  409.  
  410. "message"    is printed when the door is touched if it is a trigger door and it hasn't been fired yet
  411. "angle"        determines the opening direction
  412. "targetname" if set, no touch field will be spawned and a remote button or trigger field activates the door.
  413. "health"    if set, door must be shot open
  414. "speed"        movement speed (100 default)
  415. "wait"        wait before returning (3 default, -1 = never return)
  416. "lip"        lip remaining at end of move (8 default)
  417. "dmg"        damage to inflict when blocked (2 default)
  418. "sounds"
  419. 0)    no sound
  420. 1)    stone
  421. 2)    base
  422. 3)    stone chain
  423. 4)    screechy metal
  424. */
  425.  
  426. void() func_door =
  427.  
  428. {
  429.  
  430.     if (world.worldtype == 0)
  431.     {
  432.         precache_sound ("doors/medtry.wav");
  433.         precache_sound ("doors/meduse.wav");
  434.         self.noise3 = "doors/medtry.wav";
  435.         self.noise4 = "doors/meduse.wav";
  436.     }
  437.     else if (world.worldtype == 1)
  438.     {
  439.         precache_sound ("doors/runetry.wav");
  440.         precache_sound ("doors/runeuse.wav");
  441.         self.noise3 = "doors/runetry.wav";
  442.         self.noise4 = "doors/runeuse.wav";
  443.     }
  444.     else if (world.worldtype == 2)
  445.     {
  446.         precache_sound ("doors/basetry.wav");
  447.         precache_sound ("doors/baseuse.wav");
  448.         self.noise3 = "doors/basetry.wav";
  449.         self.noise4 = "doors/baseuse.wav";
  450.     }
  451.     else
  452.     {
  453.         dprint ("no worldtype set!\n");
  454.     }
  455.     if (self.sounds == 0)
  456.     {
  457.         precache_sound ("misc/null.wav");
  458.         precache_sound ("misc/null.wav");
  459.         self.noise1 = "misc/null.wav";
  460.         self.noise2 = "misc/null.wav";
  461.     }
  462.     if (self.sounds == 1)
  463.     {
  464.         precache_sound ("doors/drclos4.wav");
  465.         precache_sound ("doors/doormv1.wav");
  466.         self.noise1 = "doors/drclos4.wav";
  467.         self.noise2 = "doors/doormv1.wav";
  468.     }
  469.     if (self.sounds == 2)
  470.     {
  471.         precache_sound ("doors/hydro1.wav");
  472.         precache_sound ("doors/hydro2.wav");
  473.         self.noise2 = "doors/hydro1.wav";
  474.         self.noise1 = "doors/hydro2.wav";
  475.     }
  476.     if (self.sounds == 3)
  477.     {
  478.         precache_sound ("doors/stndr1.wav");
  479.         precache_sound ("doors/stndr2.wav");
  480.         self.noise2 = "doors/stndr1.wav";
  481.         self.noise1 = "doors/stndr2.wav";
  482.     }
  483.     if (self.sounds == 4)
  484.     {
  485.         precache_sound ("doors/ddoor1.wav");
  486.         precache_sound ("doors/ddoor2.wav");
  487.         self.noise1 = "doors/ddoor2.wav";
  488.         self.noise2 = "doors/ddoor1.wav";
  489.     }
  490.  
  491.  
  492.     SetMovedir ();
  493.  
  494.     self.max_health = self.health;
  495.     self.solid = SOLID_BSP;
  496.     self.movetype = MOVETYPE_PUSH;
  497.     setorigin (self, self.origin);    
  498.     setmodel (self, self.model);
  499.     self.classname = "door";
  500.  
  501.     self.blocked = door_blocked;
  502.     self.use = door_use;
  503.     
  504.     if (self.spawnflags & DOOR_SILVER_KEY)
  505.         self.items = IT_KEY1;
  506.     if (self.spawnflags & DOOR_GOLD_KEY)
  507.         self.items = IT_KEY2;
  508.     
  509.     if (!self.speed)
  510.         self.speed = 100;
  511.     if (!self.wait)
  512.         self.wait = 3;
  513.     if (!self.lip)
  514.         self.lip = 8;
  515.     if (!self.dmg)
  516.         self.dmg = 2;
  517.  
  518.     self.pos1 = self.origin;
  519.     self.pos2 = self.pos1 + self.movedir*(fabs(self.movedir*self.size) - self.lip);
  520.  
  521. // DOOR_START_OPEN is to allow an entity to be lighted in the closed position
  522. // but spawn in the open position
  523.     if (self.spawnflags & DOOR_START_OPEN)
  524.     {
  525.         setorigin (self, self.pos2);
  526.         self.pos2 = self.pos1;
  527.         self.pos1 = self.origin;
  528.     }
  529.  
  530.     self.state = STATE_BOTTOM;
  531.  
  532.     if (self.health)
  533.     {
  534.         self.takedamage = DAMAGE_YES;
  535.         self.th_die = door_killed;
  536.     }
  537.     
  538.     if (self.items)
  539.         self.wait = -1;
  540.         
  541.     self.touch = door_touch;
  542.  
  543. // LinkDoors can't be done until all of the doors have been spawned, so
  544. // the sizes can be detected properly.
  545.     self.think = LinkDoors;
  546.     self.nextthink = self.ltime + 0.1;
  547. };
  548.  
  549. /*
  550. =============================================================================
  551.  
  552. SECRET DOORS
  553.  
  554. =============================================================================
  555. */
  556.  
  557. void() fd_secret_move1;
  558. void() fd_secret_move2;
  559. void() fd_secret_move3;
  560. void() fd_secret_move4;
  561. void() fd_secret_move5;
  562. void() fd_secret_move6;
  563. void() fd_secret_done;
  564.  
  565. float SECRET_OPEN_ONCE = 1;        // stays open
  566. float SECRET_1ST_LEFT = 2;        // 1st move is left of arrow
  567. float SECRET_1ST_DOWN = 4;        // 1st move is down from arrow
  568. float SECRET_NO_SHOOT = 8;        // only opened by trigger
  569. float SECRET_YES_SHOOT = 16;    // shootable even if targeted
  570.  
  571.  
  572. void () fd_secret_use =
  573. {
  574.     local float temp;
  575.     
  576.     self.health = 10000;
  577.  
  578.     // exit if still moving around...
  579.     if (self.origin != self.oldorigin)
  580.         return;
  581.     
  582.     self.message = string_null;        // no more message
  583.  
  584.     SUB_UseTargets();                // fire all targets / killtargets
  585.     
  586.     if (!(self.spawnflags & SECRET_NO_SHOOT))
  587.     {
  588.         self.th_pain = SUB_Null;
  589.         self.takedamage = DAMAGE_NO;
  590.     }
  591.     self.velocity = '0 0 0';
  592.  
  593.     // Make a sound, wait a little...
  594.     
  595.     sound(self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
  596.     self.nextthink = self.ltime + 0.1;
  597.  
  598.     temp = 1 - (self.spawnflags & SECRET_1ST_LEFT);    // 1 or -1
  599.     makevectors(self.mangle);
  600.     
  601.     if (!self.t_width)
  602.     {
  603.         if (self.spawnflags & SECRET_1ST_DOWN)
  604.             self. t_width = fabs(v_up * self.size);
  605.         else
  606.             self. t_width = fabs(v_right * self.size);
  607.     }
  608.         
  609.     if (!self.t_length)
  610.         self. t_length = fabs(v_forward * self.size);
  611.  
  612.     if (self.spawnflags & SECRET_1ST_DOWN)
  613.         self.dest1 = self.origin - v_up * self.t_width;
  614.     else
  615.         self.dest1 = self.origin + v_right * (self.t_width * temp);
  616.         
  617.     self.dest2 = self.dest1 + v_forward * self.t_length;
  618.     SUB_CalcMove(self.dest1, self.speed, fd_secret_move1);
  619.     sound(self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
  620. };
  621.  
  622. // Wait after first movement...
  623. void () fd_secret_move1 = 
  624. {
  625.     self.nextthink = self.ltime + 1.0;
  626.     self.think = fd_secret_move2;
  627.     sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  628. };
  629.  
  630. // Start moving sideways w/sound...
  631. void () fd_secret_move2 =
  632. {
  633.     sound(self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
  634.     SUB_CalcMove(self.dest2, self.speed, fd_secret_move3);
  635. };
  636.  
  637. // Wait here until time to go back...
  638. void () fd_secret_move3 =
  639. {
  640.     sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  641.     if (!(self.spawnflags & SECRET_OPEN_ONCE))
  642.     {
  643.         self.nextthink = self.ltime + self.wait;
  644.         self.think = fd_secret_move4;
  645.     }
  646. };
  647.  
  648. // Move backward...
  649. void () fd_secret_move4 =
  650. {
  651.     sound(self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
  652.     SUB_CalcMove(self.dest1, self.speed, fd_secret_move5);        
  653. };
  654.  
  655. // Wait 1 second...
  656. void () fd_secret_move5 = 
  657. {
  658.     self.nextthink = self.ltime + 1.0;
  659.     self.think = fd_secret_move6;
  660.     sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  661. };
  662.  
  663. void () fd_secret_move6 =
  664. {
  665.     sound(self, CHAN_VOICE, self.noise2, 1, ATTN_NORM);
  666.     SUB_CalcMove(self.oldorigin, self.speed, fd_secret_done);
  667. };
  668.  
  669. void () fd_secret_done =
  670. {
  671.     if (!self.targetname || self.spawnflags&SECRET_YES_SHOOT)
  672.     {
  673.         self.health = 10000;
  674.         self.takedamage = DAMAGE_YES;
  675.         self.th_pain = fd_secret_use;    
  676.     }
  677.     sound(self, CHAN_VOICE, self.noise3, 1, ATTN_NORM);
  678. };
  679.  
  680. void () secret_blocked =
  681. {
  682.     if (time < self.attack_finished)
  683.         return;
  684.     self.attack_finished = time + 0.5;
  685.     T_Damage (other, self, self, self.dmg);
  686. };
  687.  
  688. /*
  689. ================
  690. secret_touch
  691.  
  692. Prints messages
  693. ================
  694. */
  695. void() secret_touch =
  696. {
  697. if ((other.classname != "player") && (other.classname != "cbot")) // AXXEL
  698. //    if (other.classname != "player") // Original code
  699.         return;
  700.     if (self.attack_finished > time)
  701.         return;
  702.  
  703.     self.attack_finished = time + 2;
  704.     
  705.     if (self.message)
  706.     if (other.classname == "player") // AXXEL
  707.     {    centerprint (other, self.message);
  708.         sound (other, CHAN_BODY, "misc/talk.wav", 1, ATTN_NORM);
  709.     }
  710. };
  711.  
  712.  
  713. /*QUAKED func_door_secret (0 .5 .8) ? open_once 1st_left 1st_down no_shoot always_shoot
  714. Basic secret door. Slides back, then to the side. Angle determines direction.
  715. wait  = # of seconds before coming back
  716. 1st_left = 1st move is left of arrow
  717. 1st_down = 1st move is down from arrow
  718. always_shoot = even if targeted, keep shootable
  719. t_width = override WIDTH to move back (or height if going down)
  720. t_length = override LENGTH to move sideways
  721. "dmg"        damage to inflict when blocked (2 default)
  722.  
  723. If a secret door has a targetname, it will only be opened by it's botton or trigger, not by damage.
  724. "sounds"
  725. 1) medieval
  726. 2) metal
  727. 3) base
  728. */
  729.  
  730. void () func_door_secret =
  731. {
  732.     if (self.sounds == 0)
  733.         self.sounds = 3;
  734.     if (self.sounds == 1)
  735.     {
  736.         precache_sound ("doors/latch2.wav");
  737.         precache_sound ("doors/winch2.wav");
  738.         precache_sound ("doors/drclos4.wav");
  739.         self.noise1 = "doors/latch2.wav";
  740.         self.noise2 = "doors/winch2.wav";
  741.         self.noise3 = "doors/drclos4.wav";
  742.     }
  743.     if (self.sounds == 2)
  744.     {
  745.         precache_sound ("doors/airdoor1.wav");
  746.         precache_sound ("doors/airdoor2.wav");
  747.         self.noise2 = "doors/airdoor1.wav";
  748.         self.noise1 = "doors/airdoor2.wav";
  749.         self.noise3 = "doors/airdoor2.wav";
  750.     }
  751.     if (self.sounds == 3)
  752.     {
  753.         precache_sound ("doors/basesec1.wav");
  754.         precache_sound ("doors/basesec2.wav");
  755.         self.noise2 = "doors/basesec1.wav";
  756.         self.noise1 = "doors/basesec2.wav";
  757.         self.noise3 = "doors/basesec2.wav";
  758.     }
  759.  
  760.     if (!self.dmg)
  761.         self.dmg = 2;
  762.         
  763.     // Magic formula...
  764.     self.mangle = self.angles;
  765.     self.angles = '0 0 0';
  766.     self.solid = SOLID_BSP;
  767.     self.movetype = MOVETYPE_PUSH;
  768.     self.classname = "door";
  769.     setmodel (self, self.model);
  770.     setorigin (self, self.origin);    
  771.     
  772.     self.touch = secret_touch;
  773.     self.blocked = secret_blocked;
  774.     self.speed = 50;
  775.     self.use = fd_secret_use;
  776.     if ( !self.targetname || self.spawnflags&SECRET_YES_SHOOT)
  777.     {
  778.         self.health = 10000;
  779.         self.takedamage = DAMAGE_YES;
  780.         self.th_pain = fd_secret_use;
  781.         self.th_die = fd_secret_use;
  782.     }
  783.     self.oldorigin = self.origin;
  784.     if (!self.wait)
  785.         self.wait = 5;        // 5 seconds before closing
  786. };
  787.